Completed
Branch master (93a1f2)
by Daniel
01:17
created

slugify.test.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
cc 1
c 3
b 0
f 2
nc 1
nop 0
dl 0
loc 19
rs 9.4285
1
import chai from 'chai';
2
import {slugify} from '../src/strman';
3
4
describe('Slugfiy function', () => {
5
    it('should be foo-bar', () => {
6
        let fixtures = [
7
            'foo bar',
8
            'foo bar.',
9
            'foo bar ',
10
            ' foo bar',
11
            ' foo bar ',
12
            'foo------bar',
13
            'fóõ bár',
14
            'foo ! bar',
15
            'foo ~~ bar',
16
            'foo     bar',
17
            'FOO     bar'
18
        ];
19
20
        fixtures.forEach(el => {
21
            chai.expect(slugify(el)).to.equal('foo-bar');
22
        });
23
    });
24
    it('should be foo-and-bar', () => {
25
        let fixtures = [
26
            'foo&bar',
27
            'foo&bar.',
28
            'foo&bar ',
29
            ' foo&bar',
30
            ' foo&bar ',
31
            'foo&bar',
32
            'fóõ-and---bár',
33
            'foo  &    bar',
34
            'FOO  &   bar'
35
        ];
36
37
        fixtures.forEach(el => {
38
            chai.expect(slugify(el)).to.equal('foo-and-bar');
39
        });
40
    });
41
42
    it('should be throw', () => {
43
        let fixtures = [
44
            1,
45
            [],
46
            {},
47
            1.2,
48
            false,
49
            true
50
        ];
51
52
        fixtures.forEach(el => {
53
            chai.assert.throws(slugify.bind(this, el), Error);
54
        });
55
    });
56
});
57